Namespaces

Namespaces can be used to organize components, to simplify the naming, and to avoid name conflicts. A namespace is recognizable by the double colon at the end, for example: moduleA::signal1, with moduleA as namespace.

To create a namespace, just add a name followed by a double colon to a signal in the Declaration Editor. The same rules for the namespace's name apply as for any other signal, see Edit Declarations. Several namespaces can be added to a single signal, for example, moduleA::submoduleB::signal1. Namespaces are displayed in a light-brown color.

The syntax of a namespace is as follows:

namespace:expression a1:expression :: a2:expression :: c1:expression

Signal pressure and temp are within the namespaces piketec::component2

Namespaces can be used in step lists, assesslets, and functions. Note that there is no space between the two colons.

To not confuse the namespace syntax with the syntax of slicing arrays in scripts, you must add a space between the colons when slicing arrays under certain circumstances, see Data Types - Arrays.

You can either refer to a signal by its fully qualified name, thus with the namespace, for example, piketec::component2::pressure, or use the short name, thus pressure. In order to use the short name, write the namespace into the Using namespaces field. Several namespaces must be separated by a comma. The autocompletion feature (shortcut Ctrl+Space) can be used to insert the names. They can also be copied from the Declaration Editor (shortcut Ctrl+ ALT+C), see Declaration Editor.

Two namespaces in the "Using namespaces" field of the Content view; channel name added by autocompletion

If a signal has hierarchical namespaces, like in piketec::component2::pressure, you could also write the first namespace, piketec, in the Using namespaces field. You then have to address the signal by component2::pressure.

'Using namespaces field' in the Content view

Avoid ambiguous signal names

When you enter a namespace in the Using namespaces field, the short name of the signal might be identical with another signal name. To avoid ambiguity, use the fully qualified signal name including the namespaces instead of the short one. If you want to address a namespaceless signal with the same name, add a double colon in front of it. This namespaceless double colon is interpreted by TPT as "this signal has no namespace".

Avoiding ambiguous names in a step list

Refactor namespaces

You can alter a namespace in the Declaration Editor. The namespace will automatically be adapted at nearly all places it is used in your project.

Do not change the namespaces of several signals in the Declaration Editor by using the replace function of the global search, see Global Search, because this does not alter the namespaces of the signals used in your project, for example, in a step list. Test cases and assesslets might become erroneous.

The refactoring of signal names has no effect on the Dashboard script, comments or strings.

Use the fully qualified signal name in comments and strings to be able to replace them via global search.

Expand the hierarchical folder structure

Signals with namespaces specified in the Declaration Editor or displayed in the Signal Viewer are arranged in a hierarchical folder structure. The folders can be expanded or collapsed.

Hierarchical folder structure used in the Signal Viewer

Reduce the number of sub-namespaces

The number of sub-namespaces used in the hierarchical folder structure can be reduced in the Declaration Editor , for example, to shorten the signal name length.

Sub-namespaces in the hierarchical folder structure, for example, 'Model_Root' or 'ThrottleController'

Make sure that an external name is specified in the Rename mapping flavor, see Mapping Flavor - Rename. Otherwise, the signal names will no longer be recognized in the SUT.

Select View|Declaration Editor to open the Declaration Editor. Click Show signals in namespaces hierarchically to unfold the signal name and its namespaces.

Delete one sub-namespace displayed in the hierarchy, for example, Model_Root. Select another line in the table and click OK in the message box that appears. The remaining sub-namespaces are integrated in the parent namespace structure.

Signals are renamed if the name already exists. A counter suffix will be added.

The length of the signal name was shortened in this way.